package main

import (
	"fmt"
	"net"

	"gitee.com/fcu3dx/GoLiaoTian/lib"
	"github.com/bwmarrin/snowflake"
)

func main()  {
	go lib.SignalHandler()

	conn, err := net.Dial("tcp", "127.0.0.1:8888")

	lib.FatalNotNil(err)

	var id snowflake.ID

	go lib.HandleConnection(
		conn,
		id,
		func(msg string)  {
			lib.PrintMessage(msg)
		},
		func()  {
			conn.Close()
	})

	var input string

	for {
		fmt.Scanf("%s", &input)

		fmt.Fprintf(conn, "%s\r\n", input)
	}
}
